package com.jin.webvideo.config;

import com.jin.webvideo.base.httpclient.HttpClientProxy;
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.cache.ehcache.EhCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
@Configuration
public class EhCacheConfig {
    @Bean
    public EhCacheManagerFactoryBean cacheManagerFactoryBean() {
        ClassPathResource xmlResource = new ClassPathResource("ehcache.xml");
        EhCacheManagerFactoryBean bean = new EhCacheManagerFactoryBean();
        bean.setConfigLocation(xmlResource);
        bean.setShared(true);
        return bean;
    }
    @Bean
    public EhCacheCacheManager ehCacheCacheManager(EhCacheManagerFactoryBean bean) {
        return new EhCacheCacheManager(bean.getObject());
    }

    @Bean
    public HttpClient httpClient() {
        HttpClientProxy client = new HttpClientProxy(HttpClients.custom().build());
        return client;
    }
}

